<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // var minSteps = function (s, t) {
    //   let hash = {}, n = s.length + t.length
    //   for (let c of s) {
    //     hash[c] = (hash[c] || 0) + 1
    //   }
    //   for (let c of t) {
    //     if (hash[c]) {
    //       hash[c]--
    //       n -= 2
    //     }
    //   }
    //   return n
    // };
    var minSteps = function (s, t) {
      const sArr = new Array(26).fill(0);
      const tArr = new Array(26).fill(0);
      for (const ch of s) {
        sArr[ch.charCodeAt() - 'a'.charCodeAt()]++;
      }
      for (const ch of t) {
        tArr[ch.charCodeAt() - 'a'.charCodeAt()]++;
      }
      let ans = 0;
      for (let i = 0; i < 26; i++) {
        ans += Math.abs(sArr[i] - tArr[i])
      }
      return ans;
    };
    console.log(minSteps("night", "thing"))
  </script>
</body>

</html>